
using EntityModel;
using Microsoft.EntityFrameworkCore;

namespace API
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);


            builder.Services.AddControllers();
            builder.Services.AddOpenApi();
            builder.Services.AddCors(c => {
                c.AddPolicy("DZJPolicy", p =>
                {
                    p.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });
             
            builder.Services.AddDbContext<DZJDBcontext>(opts => {
                opts.UseMySql(
                    builder.Configuration.GetConnectionString("mySqlDb"),
                    MySqlServerVersion.LatestSupportedServerVersion
                );

            });
            var app = builder.Build();

            if (app.Environment.IsDevelopment())
            {
                app.MapOpenApi();
            }

            app.UseHttpsRedirection();

            app.UseAuthorization();


            app.MapControllers();

            app.Run();
        }
    }
}
